// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   CSImpl.java

package com.sunwayhorizo.health.hl7.datatypes.common;

import com.sunwayhorizo.health.hl7.common.Hl7Exception;
import com.sunwayhorizo.health.hl7.common.VersionInfo;
import com.sunwayhorizo.health.hl7.datatypes.ANY;
import com.sunwayhorizo.health.hl7.datatypes.BL;
import com.sunwayhorizo.health.hl7.datatypes.CD;
import com.sunwayhorizo.health.hl7.datatypes.CS;
import com.sunwayhorizo.health.hl7.datatypes.ED;
import com.sunwayhorizo.health.hl7.datatypes.LIST_CR;
import com.sunwayhorizo.health.hl7.datatypes.SET_CD;
import com.sunwayhorizo.health.hl7.datatypes.ST;
import com.sunwayhorizo.health.hl7.datatypes.TYPE;
import com.sunwayhorizo.health.hl7.datatypes.UID;


// Referenced classes of package oracle.apps.ctb.hl7.types.common:
//            ANYImpl, BLImpl, EDImpl, LIST_CRAdapterImpl, 
//            NullFlavorImpl, SET_CDImpl, STImpl, TYPEImpl

/*******************************
 * 实现CD接口中新添的三个方法
 * added by : lordtan
 ******************************/
public class CSImpl extends ANYImpl
    implements CS
{

    public static final String RCS_ID = "$Header: CSImpl.java 115.27 2005/09/16 09:23:21 amchanda noship $";
    public static final boolean RCS_ID_RECORDED = VersionInfo.recordClassVersion("$Header: CSImpl.java 115.27 2005/09/16 09:23:21 amchanda noship $", "oracle.apps.ctb.hl7.types.common");
    private ST mCode;
    private static final CS nullNI = new CSImpl(valueOf("NI"));
    private static final CS nullOTH = new CSImpl(valueOf("OTH"));
    private static final CS nullNINF = new CSImpl(valueOf("NINF"));
    private static final CS nullPINF = new CSImpl(valueOf("PINF"));
    private static final CS nullUNK = new CSImpl(valueOf("UNK"));
    private static final CS nullASKU = new CSImpl(valueOf("ASKU"));
    private static final CS nullNAV = new CSImpl(valueOf("NAV"));
    private static final CS nullMSK = new CSImpl(valueOf("MSK"));
    private static final CS nullNA = new CSImpl(valueOf("NA"));
    private static final CS nullNASK = new CSImpl(valueOf("NASK"));

    protected CSImpl(ST st)
    {
        mCode = st;
    }

    protected CSImpl(CS cs)
    {
        super(true, cs);
    }

    protected CSImpl(ST st, UID uid, ST st1, ST st2)
    {
        throw ANYImpl.newUnsupportedException("CS", "constructor");
    }

    public ST code()
    {
        if(isNull().isTrue())
            return STImpl.nullST(nullFlavor());
        else
            return mCode;
    }

    public UID codeSystem()
    {
        throw ANYImpl.newUnsupportedException("CS", "codeSystem");
    }

    public ST codeSystemName()
    {
        return STImpl.nullST(NullFlavorImpl.UNK);
    }

    public ST codeSystemVersion()
    {
        return STImpl.nullST(NullFlavorImpl.UNK);
    }

    public ST displayName()
    {
        return STImpl.nullST(NullFlavorImpl.NA);
    }

    public ED originalText()
    {
        return EDImpl.nullED(NullFlavorImpl.UNK);
    }

    public LIST_CR qualifier()
    {
        return LIST_CRAdapterImpl.nullLIST_CR(NullFlavorImpl.NA);
    }

    public SET_CD translation()
    {
        return SET_CDImpl.nullSET_CD(NullFlavorImpl.NA);
    }

    public TYPE dataType()
    {
        return com.sunwayhorizo.health.hl7.datatypes.common.TYPEImpl.CS;
    }

    public static CS valueOf(String s)
    {
        ST st = STImpl.valueOf(s);
        return new CSImpl(st);
    }

    public static CD valueOf(String s, String s1)
    {
        return new CSImpl(NullFlavorImpl.NI);
    }

    public static CS nullCS()
    {
        return new CSImpl(NullFlavorImpl.NI);
    }

    public static CS valueOf(ST st, UID uid, ST st1, ST st2)
    {
        return new CSImpl(NullFlavorImpl.NI);
    }

    public ST literal()
    {
        return code();
    }

    public int hashCode()
    {
        int i = 17;
        if(isNull().isFalse())
            i = 37 * i + code().hashCode();
        return i;
    }

    public BL equal(ANY any)
    {
        if(any instanceof CS)
        {
            if(any.isNull().isTrue())
            {
                return BLImpl.FALSE;
            } else
            {
                CS cs = (CS)any;
                return code().equal(cs.code());
            }
        } else
        {
            return BLImpl.FALSE;
        }
    }

    public BL implies(CD cd)
    {
        throw ANYImpl.newUnsupportedException("CS", "implies");
    }

//    public XMLNode[] writeXML(XMLDocument xmldocument, String s)
//        throws Hl7Exception
//    {
//        XMLElement xmlelement = (XMLElement)xmldocument.createElement(s);
//        try
//        {
//            if(code() != null && code().isNull().isFalse())
//                xmlelement.setAttribute("code", code().stringValue());
//        }
//        catch(Exception exception)
//        {
//            throw new Hl7Exception(exception);
//        }
//        return (new XMLNode[] {
//            xmlelement
//        });
//    }

    public String toString()
    {
        String s = null;
        ST st = literal();
        if(isNull().isFalse() && st != null)
            s = st.toString();
        else
            s = "<Null:" + nullFlavor().toString() + ">";
        return s;
    }

    public static CS nullCS(CS cs)
    {
        String s = null;
        if(cs == null || cs.literal().stringValue() == null || cs.isNull().isTrue())
            s = "NI";
        else
            s = cs.literal().stringValue();
        if(s.equals("NI"))
            return nullNI;
        if(s.equals("OTH"))
            return nullOTH;
        if(s.equals("NINF"))
            return nullNINF;
        if(s.equals("PINF"))
            return nullPINF;
        if(s.equals("UNK"))
            return nullUNK;
        if(s.equals("ASKU"))
            return nullASKU;
        if(s.equals("NAV"))
            return nullNAV;
        if(s.equals("MSK"))
            return nullMSK;
        if(s.equals("NA"))
            return nullNA;
        if(s.equals("NASK"))
            return nullNASK;
        else
            return nullNI;
    }

	/* (non-Javadoc)
	 * @see com.sunwayhorizo.health.hl7.datatypes.CD#codeSystemEnName()
	 */
	public ST codeSystemEnName() {
		// TODO Auto-generated method stub
		return this.codeSystemEnName();
	}

	/* (non-Javadoc)
	 * @see com.sunwayhorizo.health.hl7.datatypes.CD#codeSystemChName()
	 */
	public ST codeSystemChName() {
		// TODO Auto-generated method stub
		return this.codeSystemChName();
	}

	/* (non-Javadoc)
	 * @see com.sunwayhorizo.health.hl7.datatypes.CD#codeName()
	 */
	public ST codeName() {
		// TODO Auto-generated method stub
		return this.codeName();
	}

}
